home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / reader_requests / wild / developer / coderhelp / modulebase_minimal.library.s < prev    next >
Text File  |  2000-02-23  |  3KB  |  101 lines

  1.  
  2. ; To have a working module:
  3. ; Search MODB_ and replace with ??_ (?? is the prefix of your moduledata struct)
  4. ; Search MODULETYPE and replace with the type (Display,Broker,Draw,Light,..)
  5. ; Change the LIBRARY name and BASE (w?m_SIZEOF, even if NOW are all the same)
  6. ; Add some more specific includes
  7. ; Add the tags you support at the list (find Supported)
  8. ; Set correctly the TYPES (A-H) :
  9.  
  10. ; NB: I default provide the TrackRefresh system, but you can eliminate if you want.
  11.  
  12. ; REMEMBER TO ADD THE SPECIFIC FUNCS EVEN IN THE LIST BELOW ! (*!*)
  13.  
  14.         include    WildInc.gs
  15.         include    Wild/wild.i
  16.         include PyperLibMaker.i
  17.         include    PyperMacro.i
  18.         include    Wild/modules_macros.i
  19.  
  20. MODTYPES1    EQU    TYPEA_FULLCOMPATIBLE<<24+TYPEB_FULLCOMPATIBLE<<16+TYPEC_FULLCOMPATIBLE<<8+TYPED_FULLCOMPATIBLE
  21. MODTYPES2    EQU    TYPEE_FULLCOMPATIBLE<<24+TYPEF_FULLCOMPATIBLE<<16+TYPEG_FULLCOMPATIBLE<<8+TYPEH_FULLCOMPATIBLE
  22.  
  23.         Lib    ModuleBase,1,0,18.7.1998,wdm_SIZEOF
  24.         Lib    FUNCTIONS
  25.         Lib    OpenLib
  26.         Lib    CloseLib
  27.         Lib    ExpugneLib
  28.         Lib    ExtFuncLib
  29.  
  30.         Lib    _SetModuleTags
  31.         Lib    _GetModuleTags
  32.         Lib    _SetUpModule
  33.         Lib    _CloseModule
  34.         Lib    _RefreshModule
  35.         
  36.         XREF    _SetModuleTags
  37.         XREF    _GetModuleTags
  38.         XREF    _SetUpModule
  39.         XREF    _CloseModule
  40.         XREF    _RefreshModule
  41.         XREF    _Lib_End
  42.                         ;HERE!          (*!*)
  43.         Lib    CODE
  44.  
  45.         Lib    Init
  46.         exg    a0,d0
  47.         move.l    d0,LIB_SIZE(a0)
  48.         move.l    #MODTYPES1,wm_Types(a0)
  49.         move.l    #MODTYPES2,wm_Types+4(a0)
  50.         clr.w    wm_CNT(a0)
  51.         
  52.         ; Here you can do the First init !
  53.         ; Take care !!! Preserve A0(LibBase) and D0(Don'tKnow)
  54.         
  55.         exg    a0,d0
  56.         rts
  57.  
  58.         Lib    OpenLib
  59.         add.w    #1,LIB_OPENCNT(a6)
  60.         bset    #LIBB_DELEXP,LIB_FLAGS(a6)    ; MODULES DEFAULT ARE WANTED TO FREE THEIR MEMORY WHEN CLOSED SO THE EXPUGNE FLAG IS SET ,USUALLY. CLEAR IT ONLY IF REALLY NEEDED.
  61.         
  62.         ; Here you can do any init you want, but take care: EVERY time the
  63.         ; lib is opened, this init is done. The first time-only init is
  64.         ; in the Init routine
  65.         
  66.         move.l    a6,d0
  67.         rts
  68.  
  69.         Lib    CloseLib
  70.         subq.w    #1,LIB_OPENCNT(a6)
  71.         bne.b    ExtFuncLib
  72.         btst    #LIBB_DELEXP,LIB_FLAGS(a6)
  73.         beq.b    ExtFuncLib
  74.  
  75.         Lib    ExpugneLib
  76.         movem.l    d2/a5/a6,-(sp)
  77.         tst.w    LIB_OPENCNT(a6) 
  78.         bne.b    .still_openned
  79.  
  80.         ;On this place free all resources which has been
  81.         ;allocated in init part. a6 contain library base.
  82.  
  83.         move.l    LIB_SIZE(a6),d2
  84.         move.l    a6,a5
  85.         move.l    4.w,a6
  86.         move.l    a5,a1
  87.         jsr    _LVORemove(a6)
  88.         move.l    a5,a1
  89.         moveq    #0,d0
  90.         move.w    LIB_NEGSIZE(a5),d0
  91.         sub.w    d0,a1
  92.         add.w    LIB_POSSIZE(a5),d0
  93.         jsr    _LVOFreeMem(a6)
  94.         move.l    d2,d0
  95.         movem.l    (sp)+,d2/a5/a6
  96.         rts
  97. .still_openned
  98.         Lib    ExtFuncLib
  99.         moveq    #0,d0
  100.         rts
  101.